const App = getApp()
Page({
  data: {
    tablist: [{
        classId: "main",
        className: "首页"
      },
      {
        classId: "mianmo",
        className: "面膜"
      },
      {
        classId: "mianshuang",
        className: "面霜"
      }, {
        classId: "fangshai",
        className: "防晒"
      },
      {
        classId: "jiemian",
        className: "洁面"
      },
      {
        classId: "shuangfushui",
        className: "爽肤水"
      }
    ],
    activityList:[]
  },
  onShareAppMessage: function() { //分享功能

  },
  //js执行完毕之后，执行该方法
  onLoad() {
    // this.swiperClass = this.selectComponent("#classSwiper");
    // this.swiperClass.zhishiying()
    this.getGoodsByClass('mian', 1, 10)
  },

  onReady: function() {
    console.log('onReady')

  },
  switchTab(e) {
    console.log('switchTab')
    this.swiperClass.switchTab(e)

  },
  jumpTable() {
    console.log('jumpTable')
    this.setData({
      currentTab: this.swiperClass.data.currentTab
    })
    this.getGoodsByClass('mian', 1, 10)
  },

  getGoodsByClass(classId, page, pageSize) {
    let params = {
      classId: classId,
      page: page,
      pageSize: pageSize
    }
    App.HttpService.getGoodsByClass(params).then(res => {
      console.log(res)

      if (this.data.activityList) {
        this.data.activityList = [...this.data.activityList, ...res.data.data.list]
      }

      this.setData({
        activityList: this.data.activityList,
        paginate: res.data.data.paginate
      })
    })
  },

  onShow() {},






  onReachBottom() {
    if (!this.data.paginate.hasNext) {
      return
    }
    this.getGoodsByClass('mian', this.data.paginate.next, this.data.paginate.perPage)
  },

  navigaToActiveDetail(e) {
    if (e.detail && e.detail.formId) {
      App.HttpService.postFormId(e.detail.formId)
        .then(res => {});
    }
    App.WxService.navigateTo("/pages/goods/detail/detail", {
      goodsId: e.currentTarget.dataset.id
    })
  },
  onHide() {
    console.log("onHide")
  },


})